#ifndef TOOLINVOKER_H
#define TOOLINVOKER_H

#include "rendermanager.h"
#include "tool.h"
#include "result.h"
#include <vector>
#include "brushtool.h"
#include "erasertool.h"
#include "ToolFakeSelect.h"
#include "filltool.h"
#include "TransformTool.h"
#include "magicbrushtool.h"
#include <iostream>

class ToolInvoker
{
public:
    static ToolInvoker* getInstance();
    Result executeCommand();
    void setSelectedTool(Tool*);
    Tool* getSelectedTool();
    Result invokeMousePressEvent(QMouseEvent *event);
    Result invokeMouseMoveEvent(QMouseEvent *event);
    Result invokeMouseReleaseEvent(QMouseEvent *event);
    Result invokeMouseEnterEvent(QEvent *event);
    Result invokeMouseLeaveEvent(QEvent *event);
    Result invokeKeyPressEvent(QKeyEvent *event);
    Result invokeKeyReleaseEvent(QKeyEvent *event);
    void invokeOverlayDisplay();
    void invokeDisplay();
private:
    ToolInvoker();
    Tool *selectedTool;
    vector<Tool *> tools;
    RenderManager *rendMan;
    void setupTools();

};

inline
Tool* ToolInvoker::getSelectedTool()
{
    return selectedTool;
}

inline
Result  ToolInvoker::invokeMousePressEvent(QMouseEvent *event)
{
    return selectedTool->mousePressEvent(event);
}

inline
Result  ToolInvoker::invokeMouseMoveEvent(QMouseEvent *event)
{
    return selectedTool->mouseMoveEvent(event);
}

inline
Result  ToolInvoker::invokeMouseReleaseEvent(QMouseEvent *event)
{
    return selectedTool->mouseReleaseEvent(event);
}

inline
Result  ToolInvoker::invokeMouseEnterEvent(QEvent *event)
{
    return selectedTool->mouseEnterEvent(event);
}

inline
Result  ToolInvoker::invokeMouseLeaveEvent(QEvent *event)
{
    return selectedTool->mouseLeaveEvent(event);
}

inline
Result  ToolInvoker::invokeKeyPressEvent(QKeyEvent *event)
{
    return selectedTool->keyPressEvent(event);
}

inline
Result  ToolInvoker::invokeKeyReleaseEvent(QKeyEvent *event)
{
    return selectedTool->keyReleaseEvent(event);
}

inline
void ToolInvoker::invokeOverlayDisplay(){
    selectedTool->overlayDisplay();
}

inline
void ToolInvoker::invokeDisplay(){
    selectedTool->display();
}

#endif // TOOLINVOKER_H
